Skip to content

[client] Populate NetworkAddresses on iOS for posture checks#5900

Merged
pappz merged 1 commit intonetbirdio:mainfrom
MichaelUray:fix/ios-network-addresses
Apr 16, 2026
Merged

[client] Populate NetworkAddresses on iOS for posture checks#5900
pappz merged 1 commit intonetbirdio:mainfrom
MichaelUray:fix/ios-network-addresses

Conversation

@MichaelUray
Copy link
Copy Markdown
Contributor

@MichaelUray MichaelUray commented Apr 16, 2026

Summary

The iOS GetInfo() function never populated NetworkAddresses, causing the peer_network_range_check posture check to fail for all iOS clients. The management server received empty NetworkAddresses and either blocked the peer entirely or could not evaluate network-based policies.

This adds the same networkAddresses() call that macOS, Linux, Windows, and FreeBSD already use. The function is available in the shared info.go and works on iOS via net.Interfaces().

Changes

  • client/system/info_ios.go: Call networkAddresses() and populate NetworkAddresses field in the Info struct, matching the pattern used by all other platforms

Related Issues

Fixes #3968 — Posture checks peer network range failed on iPhone
Fixes #4657 — iOS Client loses all routes when Posture Checks are enabled

Testing

This change cannot be tested without macOS + Xcode. However:

  • The networkAddresses() function is already compiled into the iOS binary (shared info.go)
  • The same function works correctly on macOS, Linux, Windows, FreeBSD, and Android
  • net.Interfaces() is available on iOS and returns interface information within the Network Extension sandbox

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • New Features

    • Network address detection now available for iOS devices
  • Bug Fixes

    • Corrected platform reference in code documentation
    • Enhanced error handling for network discovery processes

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

📝 Walkthrough

Walkthrough

The iOS GetInfo function is enhanced to discover network addresses by calling networkAddresses() and assigning results to Info.NetworkAddresses, with warning logging on failure. A comment typo referencing Android is corrected to iOS. The code adds logrus import for logging.

Changes

Cohort / File(s) Summary
iOS Network Address Discovery
client/system/info_ios.go
Added network address discovery via networkAddresses() call, populated into Info.NetworkAddresses field, with warning logging on failure. Fixed misleading comment from Android to iOS reference. Imported logrus for warning logs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mlsmaycon
  • pappz
  • lixmal

Poem

🐰 Networks dance in iOS light,
Addresses found, posture checks right,
No more Android's mistaken name,
iPhone peers now share the fame! 🍎

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: populating NetworkAddresses on iOS for posture checks, which directly addresses the PR's core objective.
Linked Issues check ✅ Passed The code changes directly address the root causes of both linked issues by populating NetworkAddresses via networkAddresses() call, enabling posture checks to function correctly.
Out of Scope Changes check ✅ Passed All changes are scoped to iOS GetInfo() network address population with minimal scope creep; the comment fix and logrus import are supporting changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description is comprehensive and well-structured, including all required sections from the template with detailed explanations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

The iOS GetInfo() function never populated NetworkAddresses, causing
the peer_network_range_check posture check to fail for all iOS clients.

This adds the same networkAddresses() call that macOS, Linux, Windows,
and FreeBSD already use.

Fixes: netbirdio#3968
Fixes: netbirdio#4657
@MichaelUray MichaelUray force-pushed the fix/ios-network-addresses branch from 268fc99 to 46733dc Compare April 16, 2026 06:16
@sonarqubecloud
Copy link
Copy Markdown

@pappz pappz self-requested a review April 16, 2026 08:04
@pappz pappz merged commit 7e4542a into netbirdio:main Apr 16, 2026
56 of 61 checks passed
MichaelUray added a commit to MichaelUray/netbird that referenced this pull request Apr 17, 2026
Upstream netbirdio#5900 added networkAddresses() to info_ios.go.
Since this PR updates the networkAddresses() signature to require
context (for the Android external iface discoverer), the iOS caller
needs the same ctx argument.
@MichaelUray MichaelUray deleted the fix/ios-network-addresses branch April 25, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: iOS Client loses all routes when Posture Checks are enabled Posture checks peer network range failed on iphone

2 participants